package ma.platform.server.core.context;

import lombok.Data;

import java.util.Objects;

@Data
public class LoginUserContext {

    private static final InheritableThreadLocal<LoginUserContext> threadLocal = new InheritableThreadLocal<>();

    private Long id;


    public static LoginUserContext getUser() {
        return Objects.isNull(threadLocal.get()) ? new LoginUserContext() : threadLocal.get();
    }

    public static void setUser(LoginUserContext user) {
        threadLocal.set(user);
    }

    public static void remove() {
        threadLocal.remove();
    }
}
